package com.lazy.netty.ex.bench;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import com.lazy.lib.util.DataQueue;
import com.lazy.netty.ex.bench.data.BenchNetListener;
import com.lazy.netty.ex.bench.data.ConsumeTask;
import com.lazy.netty.ex.bench.server.BenchServer;

public class BenchServerMain {

    public static void main(String[] args){
        BenchServer server = new BenchServer(8023);
        DataQueue<String> dataQueue = new DataQueue<String>();
        server.setListener(new BenchNetListener(dataQueue));
        
        ScheduledExecutorService scheduledExecutor  = Executors.newScheduledThreadPool(8);
        scheduledExecutor.scheduleAtFixedRate(new ConsumeTask(dataQueue), 0, 1, TimeUnit.SECONDS);
        try{
            server.start();
        }catch(Exception e){
            e.printStackTrace();
        }
    }

}
